<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>编辑家属满意度调查表</title>
	<#include "/common/resource.ftl">
    <link rel="stylesheet" href="${params.contextPath}/static/plug/layui/css/layui.css">
    <link rel="stylesheet" href="${params.contextPath}/static/css/jquery-ui.min.css">
    <script src="${params.contextPath}/static/js/jquery-ui.min.js"></script>
    <style>
        .layui-form select {display:none !important;}
    </style>
	<script type="text/javascript">
		$(function () {
            <#if (params.tag)??>
            $("#mostDissatisfiedPersonName").autocomplete({
                source: function(request, response) {
                    $.ajax({
                        url: "${params.contextPath}/web/user/listAll.json",
                        dataType: "json",
                        data: {
                            name: $("#mostDissatisfiedPersonName").val().trim()
                        },
                        success: function(data) {
                            response($.map(data.data, function(item) {
                                return {
                                    value: item.name,
                                    id: item.id
                                }
                            }));
                        }
                    });

                },
                select: function(e, ui) {
                    $("[name='mostDissatisfiedPerson']").val(ui.item.id);
                },
                maxLength: 2
            });

            $("#mostSatisfactionPersonName").autocomplete({
                source: function(request, response) {
                    $.ajax({
                        url: "${params.contextPath}/web/user/listAll.json",
                        dataType: "json",
                        data: {
                            name: $("#mostSatisfactionPersonName").val().trim()
                        },
                        success: function(data) {
                            response($.map(data.data, function(item) {
                                return {
                                    value: item.name,
                                    id: item.id
                                }
                            }));
                        }
                    });

                },
                select: function(e, ui) {
                    $("[name='mostSatisfactionPerson']").val(ui.item.id);
                },
                maxLength: 2
            });
            <#else>
            LocalStorage.registHandler("user_handler_select", function (data) {
                $('input[name="mostSatisfactionPerson"]').val(data.id);
                $('input[name="mostSatisfactionPersonName"]').val(data.name);
            });
            LocalStorage.registHandler("user1_handler_select", function (data) {
                $('input[name="mostDissatisfiedPerson"]').val(data.id);
                $('input[name="mostDissatisfiedPersonName"]').val(data.name);
            });
            </#if>
            $.ajaxRequest({
                url: '${params.contextPath}/web/room/roomList',
                data: {},
                success: function (data) {
                    if (!data.success) {
                        $.message(data.message);
                        return;
                    }
                    var record = data.data;
                    var floorStr = "<option value=''>请选择</option>";
                    for (var i = 0; i < record.length; i++) {
                        floorStr += "<option value='" + record[i] + "'>"+ record[i] +"楼</option>";
                    }
                    $("#roomId").empty();
                    $("#floorNum").append(floorStr);
                    layui.form.render();
                }
            });
			<#if (params.id)??>
				$.ajaxRequest({
					url: '${params.contextPath}/web/familySatisfactionQuestionnaire/query.json',
					data: {id: "${params.id}"},
					success: function (data) {
						if (!data.success) {
							$.message(data.message);
							return;
						}
						var record = data.data;
						for (var key in record) {
							$("[name='" + key + "']").val(record[key]);
						}
                        // 获取floorNum
                        var floorNum = record.floorNum;
                        // 获取roomNum
                        var roomNum = record.roomNum;
                        $.ajaxRequest({
                            url: '${params.contextPath}/web/room/roomList',
                            data: {floorNum: floorNum},
                            success: function (data) {
                                if (!data.success) {
                                    $.message(data.message);
                                    return;
                                }
                                var record = data.data;
                                var roomStr = "<option value=''>请选择</option>";
                                for (var i = 0; i < record.length; i++) {
                                    if (roomNum == record[i].roomNum) {
                                        roomStr += "<option value='" + record[i].id + "' selected>" + record[i].roomNum + "</option>";
                                    } else {
                                        roomStr += "<option value='" + record[i].id + "'>" + record[i].roomNum + "</option>";
                                    }
                                }
                                $("#roomId").empty();
                                $("#roomId").append(roomStr);
                                layui.form.render();
                            }
                        });
                        layui.form.render();
					}
				});
			</#if>
            $(".ajax-form").unbind().submit(function () {
                try {
                    var form = $(this);
                    if (!form.valid()) {
                        $.message("验证不通过，无法提交表单");
                        return false;
                    }

                    form.formSubmit({
                        callBack:function (data) {
                            <#if (params.tag)??>
                            history.go(-1);
                            </#if>
                        }
                    });
                } catch (e) {
                    console.log("表单提交错误：" + e);
                }
                return false;
            });
		});
	</script>
</head>
<body style="background: #eee;">
	<div class="ui-form">
		<form class="layui-form ajax-form" action="${params.contextPath}/web/familySatisfactionQuestionnaire/<#if (params.id)??>modify<#else>save</#if>.json" method="post">
			<input type="hidden" name="id" value="${params.id}" />
            <div class="layui-card">
                <div class="layui-card-header">院部</div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">楼层<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select lay-filter="floorNum" id="floorNum" name="floorNum" class="layui-input {required:true}">

                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">房间号<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select id="roomId" name="roomId" class="layui-input {required:true}">

                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">院部工作满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="satisfactoryJobSatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">院办工作人员服务热情满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="satisfactoryJobStaffSatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">院内总体环境、卫生满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="healthSatisfactionSatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">院办工作责任、效率满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="efficiencySatisfactionSatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-card">
                <div class="layui-card-header">医护部</div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">医生工作能力的满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="doctorWorkAbilitySatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">医生服务态度的满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="doctorServiceAttitudeSatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">护士工作能力的满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="nurseWorkAbilitySatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">护士服务态度的满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="nurseServiceAttitudeSatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">护士解决问题能力的满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="nurseResolveAbilitySatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-card">
                <div class="layui-card-header">餐饮部</div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">食堂饭菜满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="canteenMealSatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">食堂工作人员的服务态度满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="canteenWorkerServiceSatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">食堂及餐厅卫生状况满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="canteenHealthSatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-card">
                <div class="layui-card-header">安保部</div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">安全满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="safetySatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">门卫责任满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="doormanResponsibilitySatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">安保工作满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="securityJobSatisfaction" class="layui-input">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-card">
                <div class="layui-card-header">市场部</div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">市场部介绍满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="marketingIntroducesSatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">市场部参观满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="marketingVisitSatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">市场部服务满意度<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <select name="marketingServiceSatisfaction" class="layui-input {required:true}">
                                        <option value="">请选择</option>
                                        <option value="1">满意(5分)</option>
                                        <option value="2">一般(3分)</option>
                                        <option value="3">不满意(2分)</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-card">
                <div class="layui-card-header">意见和建议</div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <#if (params.tag)??>
                            <div class="layui-form-item">
                                <label class="layui-form-label">最满意工作人员<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="hidden" name="mostSatisfactionPerson" id="mostSatisfactionPerson" value=""/>
                                    <input type="text" id="mostSatisfactionPersonName" name="mostSatisfactionPersonName" class="layui-input" autocomplete="off"/>
                                </div>
                            </div>
                            <#else>
                            <div class="layui-form-item">
                                <label class="layui-form-label">最满意的工作人员<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="hidden" name="mostSatisfactionPerson" />
                                    <input type="text" name="mostSatisfactionPersonName" placeholder="请选择工作人员"
                                           p="model:'user',handlerId:'user_handler_select'"
                                           class="layui-input single-model-select {required:true}" readonly>

                                </div>
                            </div>
                            </#if>
                        </div>
                        <div class="layui-col-md6">
                            <#if (params.tag)??>
                            <div class="layui-form-item">
                                <label class="layui-form-label">最不满意工作人员<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="hidden" name="mostDissatisfiedPerson" id="mostDissatisfiedPerson" value=""/>
                                    <input type="text" id="mostDissatisfiedPersonName" name="mostDissatisfiedPersonName" class="layui-input" autocomplete="off"/>
                                </div>
                            </div>
                            <#else>
                            <div class="layui-form-item">
                                <label class="layui-form-label">最不满意工作人员<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="hidden" name="mostDissatisfiedPerson" />
                                    <input type="text" name="mostDissatisfiedPersonName" placeholder="请选择工作人员"
                                           p="model:'user1',handlerId:'user1_handler_select'"
                                           class="layui-input single-model-select {required:true}" readonly>
                                </div>
                            </div>
                            </#if>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md12">
                            <div class="layui-form-item">
                                <label class="layui-form-label">建议</label>
                                <div class="layui-input-block">
                                    <textarea type="text" name="suggestion" class="layui-textarea" maxlength="500"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="submit" value="保存" class="layui-btn" />
				</div>
			</div>
		</form>
	</div>
</body>
<script src="${params.contextPath}/static/plug/layui/layui.all.js"></script>
<script>

    layui.use(['element','form'], function() {
        var form = layui.form;
        form.on('select(floorNum)', function (data) {
            $.ajaxRequest({
                url: '${params.contextPath}/web/room/roomList',
                data: {floorNum: $("[name='floorNum']").val()},
                success: function (data) {
                    if (!data.success) {
                        $.message(data.message);
                        return;
                    }
                    var record = data.data;
                    var roomStr = "<option value=''>请选择</option>";
                    for (var i = 0; i < record.length; i++) {
                        roomStr += "<option value='" + record[i].id + "'>" + record[i].roomNum + "</option>";
                    }
                    $("#roomId").empty();
                    $("#roomId").append(roomStr);
                    layui.form.render();
                }
            });
        });
    });
</script>
</html>
